class Solution:
    def reverseKGroup(head: ListNode, k: int) -> ListNode:
        # write code here
        L = []
        for i in range(len(head)//k):
            L = L + head[i*k:(i+1)*k][::-1]
        if len(head)%k != 0:
            L = L + head[-(len(head)%k):]
        print("{",end='')
        print(",".join(L), end = '')
        print("}")

s = input()
for i in range(len(s)):
    if s[i] == '}':
        Solution.reverseKGroup(list(map(str, s[1:i].split(','))), int(s[i+2:]))
        break